/***************************************************************
 * 系统名称           : 生鲜MIS系统
 * 处理内容           : 继承TreeList
 * @author            : 
 * @Modify            : geping@2020-10-30
 * @description       : 
 * @version           : v1.0
 * @Copyright         : 宁波康铭泰克信息科技有限公司
 ***************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DevExpress.XtraTreeList;
using DevExpress.XtraTreeList.Columns;

namespace Comteck.Winforms.Controls {
  /// <summary>
  /// 
  /// </summary>
  public class MyTreeList : TreeList {
    // TODO


    /// <summary>
    /// 根据DPI重新计算列宽
    /// </summary>
    private void ReCaculateWidthByDPI() {
      if (!this.IsAutoWidth) {
        var sizeF = SysGlobal.DpiSizeF == null ? this.ScaleFactor : SysGlobal.DpiSizeF;
        foreach (TreeListColumn column in this.Columns) {
          column.Width = DevExpress.Skins.RectangleHelper.ScaleHorizontal(column.Width, sizeF.Width);
        }
      }
    }

    /// <summary>
    /// 在初始化后注册一些事件
    /// </summary>
    public override void EndInit() {
      base.EndInit();

      this.ReCaculateWidthByDPI();
    }
  }
}
